#region Using directives

using System;

using FighterChessEngine.Enum;
using FighterChessEngine.FC_Board;

#endregion

namespace FighterChessEngine.FC_Fighter.Fighters
{
    /// <summary>
    /// Summary description for Bishop.
    /// </summary>
    public class Bishop : Fighter
    {
        #region Atributes
        #endregion

        #region Properties
        #endregion

        #region Methods
        public Bishop() : base()
        {
            Init();
            level = 3;
        }

        public Bishop(Owner owner, Square pos) : base(owner, pos)
        {
            Init();
            level = 3;
        }

        public Bishop(string strBishop)
            : base(strBishop)
        {
            Init();
        }

        private void Init()
        {
            name = "Bishop";
            symbol = "B";
            type = FighterType.Bishop;
        }

        public override void UpdateNextPositions(Fighter[,] fighters)
        {
            base.UpdateNextPositions(fighters);

            int row = currentPos.Row;
            int col = currentPos.Col;

            // top-left side
            row = currentPos.Row;
            col = currentPos.Col;
            row--;
            col--;
            while (1 == 1)
            {
                if (col < 0 || row < 0) // out of board
                {
                    break;
                }

                if (AddStopPosition(fighters, row, col))
                    break;

                arrNextPos.Add(new Square(row, col));
                row--;
                col--;
            }

            // bottom-right side
            col = currentPos.Col;
            row = currentPos.Row;
            col++;
            row++;
            while (1 == 1)
            {
                if (col > 7 || row > 7) // out of board
                {
                    break;
                }

                if (AddStopPosition(fighters, row, col))
                    break;

                arrNextPos.Add(new Square(row, col));
                col++;
                row++;
            }

            // top-right side
            row = currentPos.Row;
            col = currentPos.Col;
            col++;
            row--;
            while (1 == 1)
            {
                if (row < 0 || col > 7) // out of board
                {
                    break;
                }

                if (AddStopPosition(fighters, row, col))
                    break;

                arrNextPos.Add(new Square(row, col));
                col++;
                row--;
            }

            // bottomm-left side
            row = currentPos.Row;
            col = currentPos.Col;
            row++;
            col--;
            while (1 == 1)
            {
                if (row > 7 || col < 0) // out of board
                {
                    break;
                }

                if (AddStopPosition(fighters, row, col))
                    break;

                arrNextPos.Add(new Square(row, col));
                row++;
                col--;
            }
        }
        #endregion
    }
}
